﻿from django.shortcuts import redirect
from django.utils.deprecation import MiddlewareMixin

white_list1 = [
    '/seller/login/',
    '/seller/register/',
    '/',
]


class MD1(MiddlewareMixin):
    def process_request(self, request):
        #  给以buyer开头的url放行
        if request.path_info.find('/buyer') != -1:
            return None
        if request.path_info in white_list1:
            return None
        name = request.COOKIES.get('name')
        if name:
            return None
        else:
            return redirect('/seller/login/')
